import axios from '../utils/request'
// axios.defaults.baseURL = 'http://www.liulongbin.top:3008'

// (loginForm) => {}
export const loginForm = (loginForm) => {
  return axios({
    url: '/api/login',
    method: 'post',
    data: loginForm
  })
}
/* 封装接口,单独抽离出来,
1.export按需导出
2.(regForm)接收reg/index调用次方法后传的值
3.因为获取promise里面的值,需要用.then/asyne await
4.axios获取的是promise对象,需要用return返回出来
*/
export const reqRegister = (regForm) => {
  return axios({
    url: '/api/reg',
    method: 'post',
    data: regForm
  })
}
// 1封装接口,获取用户信息
export const reqGetUserInfo = () => {
  return axios({
    url: '/my/userinfo',
    method: 'get'
    // 自定义请求头,
    // headers: {
    //   Authorization: localStorage.getItem('token')
    // }
  })
}
// 更换头像
export const avatarApi = avatar => {
  return axios({
    method: 'patch',
    url: '/my/update/avatar',
    data: {
      avatar
    }
  })
}
